package com.blog.controller.frontpage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.blog.controller.base.BaseServlet;
import com.blog.entity.ArticleConstraintEntity;
import com.blog.entity.TypesEntity;
import com.blog.service.frontpage.ArticleService;
import com.blog.service.frontpage.IndexService;

@WebServlet("/type5")
public class TypeServlet5 extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 查询分类
		IndexService service = new IndexService();
		List<TypesEntity> typesList = service.getAllTypesInfo();
		req.setAttribute("typesList", typesList);

		// 查询首页所有热门推荐详情
		ArticleService articleService = new ArticleService();
		List<ArticleConstraintEntity> hotRecommendList = articleService.getHotRecommend();
		req.setAttribute("hotRecommendList", hotRecommendList);

		// 查询此类别的所有文章
		String value = req.getParameter("value");
		List<ArticleConstraintEntity> articleList = articleService.getArticleByTypes(value);
		req.setAttribute("articleList", articleList);
		forward("llpfrontpage/type5");
	}
}
